/**
 * Created by shi.pengyan on 2016-12-29.
 */

import http from '../../../common/httpUtil';
import * as types from './appointmentsMutationTypes';

const actions = {

/*  queryAppointment({ commit }, { userId } = {}) {
    //commit(types.APPOINTMENT_QUERY_APPOINTMENT_BEGIN);

    return http.get(`sys/user/${userId}`).then(user => {
      //commit(types.APPOINTMENT_QUERY_APPOINTMENT_SUC, {user});
      return user;
    })
  },*/

//{"success":true,"result":{"firstResult":0,"pageCount":2,"pageNow":1,"pageSize":10,"pagecode":10,"records":[{"appointmentId":18,"appointmentTime":1488265824000,"clientMobile":"13819152672","clientName":"test","createDate":1488265824000,"createUserId":"104","isValid":true,"productId":1,"productName":"科地资管5号"},{"appointmentId":17,"appointmentTime":1488163649000,"clientMobile":"13819152672","clientName":"张三","createDate":1488163649000,"createUserId":"229","isValid":true,"productId":1,"productName":"科地资管5号"},{"appointmentId":16,"appointmentTime":1487903465000,"clientMobile":"15005858853","clientName":"车驰","createDate":1487903465000,"createUserId":"229","isValid":true,"productId":1,"productName":"科地资管5号产业园分级投资基金"},{"appointmentId":15,"appointmentTime":1487732445000,"clientMobile":"13300000001","clientName":"哦哦哦","createDate":1487732445000,"createUserId":"176","isValid":true,"productId":2,"productName":"科地资管8号产业园分级投资基金"},{"appointmentId":14,"appointmentTime":1485178707000,"clientMobile":"13200000009","clientName":"车驰","createDate":1485178707000,"createUserId":"272","isValid":true,"productId":1,"productName":"科地资管5号产业园分级投资基金"},{"appointmentId":13,"appointmentTime":1484997567000,"clientMobile":"13200000009","clientName":"车驰","createDate":1484997567000,"createUserId":"272","isValid":true,"productId":1,"productName":"科地资管5号产业园分级投资基金"},{"appointmentId":12,"appointmentTime":1484535092000,"clientMobile":"15005858853","clientName":"车驰","createDate":1484535092000,"createUserId":"229","isValid":true,"productId":1,"productName":"科地资管5号产业园分级投资基金"},{"appointmentId":11,"appointmentTime":1484405403000,"clientMobile":"13200000009","clientName":"车驰","createDate":1484405403000,"createUserId":"272","isValid":true,"productId":1,"productName":"科地资管5号产业园分级投资基金"},{"appointmentId":10,"appointmentTime":1484383848000,"clientMobile":"15005858885","clientName":"车驰","createDate":1484383848000,"createUserId":"229","isValid":true,"productId":1,"productName":"科地资管5号产业园分级投资基金"},{"appointmentId":9,"appointmentTime":1484382145000,"clientMobile":"15005858853","clientName":"chechi","createDate":1484382145000,"createUserId":"229","isValid":true,"productId":1,"productName":"科地资管5号产业园分级投资基金"}],"rowCount":18,"startPage":0}}
  queryAppointments ({ commit }, {pageIndex = 1, pageSize = 10, isActive = true, productName = '', clientName = '', mobile = ''} = {}) {
    commit(types.APPOINTMENT_QUERY_APPOINTMENTS_BEGIN, {pageSize});

    return http.get(`pe/query/appointments?pageIndex=${pageIndex}&pageSize=${pageSize}&isActive=${isActive}&productName=${productName}&clientName=${clientName}&mobile=${mobile}`)
      .then(appointments => {
        commit(types.APPOINTMENT_QUERY_APPOINTMENTS_SUC, appointments);
      })
  }


};


export default actions;
